// document.write("<script language='javascript' src='/resources/js/views/defineTable.js'></script>");

var action_area_selfCity = "/area/query/selfCity.do";
var action_area_query_county="/area/query/county.do";

var page = 1;
var pageSize = 30;

function loadCityDepart(){
    var formsid=$('#formid').combobox('getValue');
    $.get(action_area_selfCity, {'formsid':formsid},function (json) {
        $('#fieldAnalysis_citySelect').combobox({
            async:false,
            method:'GET',
            data:json.data,
            editable:true,
            valueField:'id',
            textField:'name',
            onLoadSuccess: function () {
                var a = $('#fieldAnalysis_citySelect').combobox('getData');
                if (a.length > 0) {
                    $('#fieldAnalysis_citySelect').combobox('select', a[0].id);
                }
            }
        })
    },
    'json');
}

function loadCityAndCountyDepart(){
    var formsid=$('#formid').combobox('getValue');
    $.get(action_area_selfCity, {'formsid':formsid},function (json) {
        $('#fieldAnalysis_citySelect').combobox({
            async:false,
            method:'GET',
            data:json.data,
            editable:true,
            valueField:'id',
            textField:'name',
            onLoadSuccess: function () {
                var a = $('#fieldAnalysis_citySelect').combobox('getData');
                if (a.length > 0) {
                    $('#fieldAnalysis_citySelect').combobox('select', a[0].id);
                }
            },
            onSelect:function (city) {
                loadCountyDepart(action_area_query_county, city.id);
            }
        })
    },
    'json');
}


//加载区县下拉列表
function loadCountyDepart(action_url, id){
    $.get(action_url, {"areaid":id}, function (json) {
        // json.data.unshift({id : -1,name : "全部",sname : "全部"});
        $('#countySelect').combobox({
            async:false,
            method:'GET',
            data:json.data,
            editable:true,
            valueField:'id',
            textField:'name',
            onLoadSuccess: function () {
                var a = $('#countySelect').combobox('getData');
                if (a.length > 0) {
                    $('#countySelect').combobox('select', a[0].id);
                }
            }
        })
    }, "json");
}